<script setup lang="ts">
	import { reactive, ref } from "vue";
	import shopGoodsCard from "@/components/shop-goods-card/shop-goods-card.vue"
	import {
		useRouter
	} from 'uni-mini-router'
	import {
		getCurrentInstance
	} from 'vue'
	import {
		onShow,
		onHide,
		onLoad,
		onReachBottom
	} from '@dcloudio/uni-app'
	import {
		userStore
	} from '@/pinia';
	let router = useRouter()
	const userStoreInfo = userStore();
	const {
		proxy,
	} = getCurrentInstance()
	let cateId = ref()
	let goodsType = ref(0)
	onLoad((options) => {
		console.log(options);
		cateId.value = options.id
		goodsType.value = options.type
		uni.setNavigationBarTitle({
			title: options.name
		})
		getList()
	})
	let pageNum = ref(1)
	let goodsList = ref([])
	onReachBottom(() => {
		pageNum.value++
		getList()
	})
	const getList = () => {
		proxy.$req('GET', proxy.$api.commonGoodsList, {
			isType: goodsType.value,
			cateId: cateId.value,
			pageNo: pageNum.value,
			pageSize: '14'
		}).then((res) => {
			console.log(res);
			goodsList.value = goodsList.value.concat(res.result.records)
		})
	}
</script>
<template>
	<view class="aa" v-if="goodsList.length>0">
		<shop-goods-card :list="goodsList"></shop-goods-card>
	</view>
</template>
<style lang="scss">
	page {
		background-color: #fafafa;
	}

	view {
		box-sizing: border-box;
	}

	.aa {
		width: 686rpx;
		padding: 32rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		margin: 32rpx auto 0;
	}
</style>